package com.sskj.ffex.v.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import com.sskj.ffex.R;
import com.sskj.ffex.common.App;
import com.sskj.ffex.common.widget.ToolBarLayout;
import com.sskj.ffex.m.bean.UserInfo;
import com.sskj.ffex.p.activity.SellerApplyPresenter;
import com.sskj.ffex.utils.ClickUtil;
import com.sskj.ffex.utils.ToastUtil;
import com.sskj.ffex.v.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 申请商家
 */
public class SellerApplyActivity extends BaseActivity<SellerApplyPresenter> {
//    @BindView(R.id.iv_back)
//    ImageView ivBack;

    @BindView(R.id.bt_apply_seller)
    Button btApplySeller;
    @BindView(R.id.apply_checkbox)
    CheckBox mApplyCheckbox;
    @BindView(R.id.tv_freeze)
    TextView tvFreeze;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.toolBar)
    ToolBarLayout toolBar;
    @BindView(R.id.title)
    TextView title;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_seller_apply;
    }

    @Override
    public SellerApplyPresenter getPresenter() {
        return new SellerApplyPresenter();
    }

    public static void start(Context context) {
        Intent starter = new Intent(context, SellerApplyActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void initView() {
        mPresenter.requestUserInfo();
//        ClickUtil.click(ivBack, this::finish);
        toolBar.setLeftButtonOnClickLinster(v -> finish());
        toolBar.setTitle(App.INSTANCE.getString(R.string.strSellerApplyActivity200));
        title.setVisibility(View.GONE);
        ClickUtil.click(btApplySeller, () -> {
            if (mApplyCheckbox.isChecked()) {
                mPresenter.apply();
            } else {
                ToastUtil.getInstance(this).showMessage(App.INSTANCE.getString(R.string.strSellerApplyActivity201));
            }
        });
    }


    public void startFabiPublish() {
        finish();
        FabiPublishActivity.start(this);
    }

    public void updateUser(UserInfo data) {
        tvContent.setText(App.INSTANCE.getString(R.string.strSellerApplyActivity202) + data.getUsdt() + App.INSTANCE.getString(R.string.strSellerApplyActivity203));
        tvFreeze.setText(App.INSTANCE.getString(R.string.strSellerApplyActivity204) + data.getUsdt() + App.INSTANCE.getString(R.string.strSellerApplyActivity205));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
